//////////////////////////////////////////////////////////////////////////
// Project:			DTString
// Description:		DTString is a String using the standard C++ coding of the class,
//				in order to be compatible with the MFC code
// Change Time:		2012-2-9 14:13:38
// Code by ccnyou 
//
// Change Time:		2012-2-11 for add some method by ccnyou
//////////////////////////////////////////////////////////////////////////

#ifndef _DTSTRING_H
#define _DTSTRING_H

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

typedef const char* DTPCSTR,*DTLPCTSTR;
typedef char TCHAR;

//#define _MACOS

#ifdef _MACOS
#import <Foundation/Foundation.h>
typedef NSString *PCNSSTRING;
#endif

class DTString
{
private:
	string m_string;
public:
	DTString(const char *pStr);
	DTString();
	~DTString();
	
	int GetLength();

	int Find( TCHAR ch ) const;
	int Find( DTLPCTSTR lpszSub ) const;
	int Find( TCHAR ch, int nStart ) const;
	int Find( DTLPCTSTR pstr, int nStart ) const;

	DTString Right( int nCount ) const;
	DTString Left( int nCount ) const;
	
	const DTString &operator = (const char *pStr);
	const DTString &operator += (const char *pStr);
    friend DTString operator+(const DTString &str1,const char *pStr);
	
	const DTString &operator = (const DTString &Str);
	const DTString &operator+=(const DTString &Str);
	friend DTString operator+(const DTString &Str1,const DTString &Str2);
	
	const DTString &operator = (const string &Str);
	const DTString &operator += (const string &Str);
    friend DTString operator + (const DTString &Str1,const string &Str);
    
    
#ifdef _MACOS
    
    DTString(NSString *Str);
    DTString &LoadNSString(NSString *str);
    DTString &operator = (NSString *Str);
    NSString *ns_str() const;
  
	operator PCNSSTRING() const;
 
#endif
	
	operator DTPCSTR() const;
	
	friend istream &operator >>(istream &is,DTString &str);
	friend ostream &operator <<(ostream &os,DTString &str);

};




#endif